DEF_PROJECT=../../..
include $(DEF_PROJECT)/scripts/main.mk
name=bzip2
version=1.0.6
prefix=/usr
destdir=$(DIR_SYSROOT)
extdeps=eglibc-tools gcc-tools binutils-tools linux-header-tools

DL_SERV=http
DL_HOST=www.bzip.org
DL_PATH=$(version)
DL_SUFFIX=tar.gz

mflags+=CC=$(addsuffix -,$(CC_TARGET))gcc AR=$(addsuffix -,$(CC_TARGET))ar RANLIB=$(addsuffix -,$(CC_TARGET))ranlib

iflags+=PREFIX=$(destdir)/usr

pre-build:
	cp -n $(source)/Makefile{,.orig}
	sed -e "/^all:/s/ test//" $(source)/Makefile.orig > $(source)/Makefile
	sed -i -e 's@ln -s -f $$(PREFIX)/bin/@ln -s @' $(source)/Makefile
	$(MAKE) -C $(if $(build),$(build),$(source)) -f Makefile-libbz2_so $(mflags)
	$(MAKE) -C $(source) clean

post-build:
	rm -f $(destdir)/usr/bin/{bunzip2,bzcat,bzip2,bzegrep,bzfgrep,bzless,bzcmp}
	$(MAKE) -C $(if $(build),$(build),$(source)) $(iflags)
	cp -af $(source)/bzip2-shared $(destdir)/$(prefix)/bin/bzip2
	cp -af $(source)/libbz2.so* $(destdir)/lib
	ln -sf ../../lib/libbz2.so.1.0 $(destdir)/usr/lib/libbz2.so
	rm -f $(destdir)/usr/bin/{bunzip2,bzcat,bzip2}
	#ln -sf bzip2 $(destdir)/bin/bunzip2
	#ln -sf bzip2 $(destdir)/bin/bzcat


